<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JavaScript中的Switch</title>
</head>
<body>
    <h3>
        <center>
            <button onclick="Myfunction()">星期几？</button>
        </center>
    </h3>
<hr>
<h1 id="demo">
    <center>

    </center>
</h1>

<script>
    function Myfunction() {
        var x;
        var d = new Date().getDay();
        switch (d) {
            case 0:
                x = "今天是星期日";
                break;
            case 1:
                x = "今天是星期一";
                break;
            case 2:
                x = "今天是星期二";
                break;
            case 3:
                x = "今天是星期三";
                break;
            case 4:
                x = "今天是星期四";
                break;
            case 5:
                x = "今天是星期五";
                break;
            case 6:
                x = "今天是星期六";
                break;
        }
        document.getElementById("demo").innerHTML = x;
    }
</script>
</body>
</html>